package com.im.partchat.http.service;

import com.im.partchat.bean.Department;
import com.im.partchat.bean.User;
import com.im.partchat.bean.UserBean;
import com.im.partchat.bean.reponsed.BaseResponse;
import com.im.partchat.bean.request.ChangePawRequest;
import com.im.partchat.bean.request.LoginRequest;
import com.im.partchat.bean.request.RequestBean;
import com.im.partchat.bean.request.UserListRequest;
import com.im.partchat.http.api.UserApi;
import com.im.partchat.http.apiManager.ApiManager;
import com.im.partchat.http.apiManager.LoginApiManager;

import java.util.List;

import io.reactivex.Observable;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.schedulers.Schedulers;

/**
 * Created by fzl on 2017/6/27 0027.
 * VersionCode: 1
 * Desc:
 */

public class UserService  {


    public static Observable<BaseResponse<UserBean>> login(RequestBean<LoginRequest> userLogin) {
        UserApi loginApi = LoginApiManager.getInstance();
        return loginApi.login(userLogin)
                .observeOn(AndroidSchedulers.mainThread())
                .subscribeOn(Schedulers.io());
    }
    public static Observable<BaseResponse<List<User>>> getUserList(RequestBean<UserListRequest> request) {

        return ApiManager.getInstance().getApi(UserApi.class).getUserList(request)
                .observeOn(AndroidSchedulers.mainThread())
                .subscribeOn(Schedulers.io());
    }
    public static Observable<BaseResponse<List<Department>>> getDepartment() {
        return ApiManager.getInstance().getApi(UserApi.class).getDeptList(new Object())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribeOn(Schedulers.io());
    }

    public static Observable<BaseResponse<String>> changePaw(RequestBean<ChangePawRequest> request) {
        return ApiManager.getInstance().getApi(UserApi.class).changePaw(request)
                .observeOn(AndroidSchedulers.mainThread())
                .subscribeOn(Schedulers.io());
    }

}
